Repository navigation
Add a simple DeviceSpec class. - #83
Conversation
This is a straightforward port from device_spec.py. https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/framework/device_spec.py
|
Do you know if the Auto value stuff will be upgraded to use Records (https://openjdk.java.net/jeps/384) when it comes out of preview? As otherwise it might be preferable to use plain Java classes that we can convert into records when support comes (as I think it's supposed to be a binary compatible change). |
I don't :) Also taking a look at the record, it doesn't seem supporting a customer builder or stuff like that? In our case, the values are optional - the default null value builder seems cleaner ATM. |
|
Yeah, you have to specify the builder by hand, those aren't part of the language support for records. Though you can have multiple constructors for a record provided they call into the canonical constructor. |
|
Thanks for the PR @hthu , I would suggest having a builder that does not depend on any external library. We had unfortunately no choice with |
|
Oops, totally forgot about this. |
|
Updated to a version without auto. |
| @@ -0,0 +1,166 @@ | |||
| package org.tensorflow.device; | |||
|
|
|||
| import com.google.common.base.Joiner; | |||
There was a problem hiding this comment.
Sorry @hthu , you should not use Guava neither :)
Guava is present in the classpath at compile time only as a result of depending on tensorflow-core-generator for running the annotation processor. As you can see in the pom, this dependency is optional, meaning that it will not be automatically present at runtime nor its transitive dependencies. I'm even surprised they were included when running your unit tests.
Again, sorry for the trouble but I think we should try to avoid adding a new runtime dependency in the core module if there is an easy way to accomplish the same task without it.
| @@ -0,0 +1,162 @@ | |||
| package org.tensorflow.device; | |||
|
|
|||
| import javax.annotation.Nullable; | |||
There was a problem hiding this comment.
Where do we get the Nullable annotation from? It's not in the JDK.
There was a problem hiding this comment.
I was wondering as well, I assumed (maybe a bit too fast) that it was part of the JDK... ok, I'll remove them manually and merge back the file without it
There was a problem hiding this comment.
Yeah, it was coming again from our dependency to the tensorflow-core-generator, which got it from com.google.code.findbugs, thanks for raising this @Craigacp
There was a problem hiding this comment.
Woah I always thought @nullable was part of the JDK somewhere...
My bad for taking that for granted.
Are you folks already removing that?
There was a problem hiding this comment.
No worries. Can we remove the generator dependency somehow? It pulls in a lot of things.
There was a problem hiding this comment.
Personally I'm a bit confused as to why jsr305 wasn't integrated into the JDK, but there was a talk about nullness annotations from Google at the last JVMLS discussing all the issues with integrating them into things, and it seemed to be pretty complex. Unfortunately that talk wasn't recorded.
There was a problem hiding this comment.
Can we remove the generator dependency somehow?
I was thinking of doing that as well but there is probably a good reason why it is there, probably maven was failing somehow to run the annotation processor without it. Will need to double check
So @hthu , it's all good now, I forced-pushed a new version without @Nullable. I also took the opportunity to move the DeviceSpec out of the device package. Since there was only one file in that package, I don't think we needed it.
There was a problem hiding this comment.
Sounds good to me!
Thank you both!
There was a problem hiding this comment.
Can we remove the generator dependency somehow?
I was thinking of doing that as well but there is probably a good reason why it is there, probably maven was failing somehow to run the annotation processor without it. Will need to double check
I guess without the explicit dependency it's up to maven which one of the generator and the core api it compiles first. Maybe we could make it a test time dependency? That's even less clear in terms of the semantics, but it should make it run first.
This is a straightforward port from device_spec.py.
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/framework/device_spec.py